<?php
/**
 * +--------------------------------------------------------+
 * @Created by PhpStorm.
 * @Category OperationLogService.php
 * @Depiction:
 * Author: hwy
 * Date: 2021/2/20  16:52
 * +--------------------------------------------------------+
 */

namespace App\Services;


use App\Models\OperationLog;
use Illuminate\Support\Facades\Redis;

class OperationLogService extends BaseService
{
    protected $operation_log;

    public function __construct()
    {
        $this->operation_log = new OperationLog();
    }

    public function addData()
    {
        $cache_name_log = 'log_operation';
        $resid_log_data = Redis::lrange($cache_name_log, 0, 100);
        Redis::ltrim($cache_name_log, 100, -1);
        $insert_data = [];

        foreach ($resid_log_data as $val) {
            $insert_data[] = json_decode($val, true);
        }

        self::insert($insert_data);
        return true;
    }

}
